<!DOCTYPE html>
<html class="x-admin-sm">
{include file="common/static" /}
    <body>
        <div class="layui-fluid">
            <div class="layui-row">
                <form class="layui-form">
                    <div class="layui-form-item">
                        <label for="username" class="layui-form-label">
                            <span class="x-red">*</span>姓名
                        </label>
                        <div class="layui-input-inline">
                            <input type="text" id="surname" name="username" required="" lay-verify="required"
                                   autocomplete="off" class="layui-input" value="{$staff.surname}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label for="username" class="layui-form-label">
                            <span class="x-red">*</span>手机号
                        </label>
                        <div class="layui-input-inline">
                            <input type="text" id="tel" name="username" required="" lay-verify="required"
                                   autocomplete="off" class="layui-input" value="{$staff.tel}">
                        </div>
                    </div>
                  <div class="layui-form-item">
                      <label for="username" class="layui-form-label">
                          <span class="x-red">*</span>登录名
                      </label>
                      <div class="layui-input-inline">
                          <input type="text" id="user" name="username" required="" lay-verify="required"
                          autocomplete="off" class="layui-input" value="{$staff.username}">
                      </div>
                  </div>

                    <div class="layui-form-item">
                        <label for="username" class="layui-form-label">
                            <span class="x-red">*</span>密码
                        </label>
                        <div class="layui-input-inline">
                            <input type="text" id="password" name="username" required="" lay-verify="required"
                                   autocomplete="off" class="layui-input" placeholder="不填则不需要修改">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label for="username" class="layui-form-label">
                            <span class="x-red">*</span>楼栋</label>
                        <div class="layui-input-inline">
                            <select name="shipping" class="valid" id="building_id">
                                {volist name='building' id='vv'}
                                    {if $vv['id'] == $staff['building_id'] }
                                        <option value="{$vv.id}">{$vv.building}</option>
                                    {/if}
                                {/volist}

                                {volist name='building' id='vv'}
                                <option value="{$vv.id}">{$vv.building}</option>
                                {/volist}

                            </select>
                        </div>
                    </div>

                  <div class="layui-form-item">
                      <label for="L_repass" class="layui-form-label">
                      </label>
                      <button  class="layui-btn" type="button" onclick="edits({$staff.id})">
                          增加
                      </button>
                  </div>
              </form>
            </div>
        </div>

    </body>
<script>

    layui.use(['form', 'layer'],
            function() {
                $ = layui.jquery;
                var form = layui.form,
                        layer = layui.layer;
            });
    function edits(id){
        $.ajax({
            type:"post",
            url: "{:url('index/admins/edits')}",
            data: {
                id:id,
                username:$('#user').val(),
                password:$('#password').val(),
                building_id:$('#building_id').val(),
                tel:$('#tel').val(),
                surname:$('#surname').val()
            },
            success: function(data){
                console.log(data);
                toastr.error(data.msg);
                if(data.code == 100){
                    setTimeout(function () {
                        layer.closeAll();
                        parent.location.reload();
                    },1500);
                }
            }});
    }
</script>

</html>
